<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
    <meta property="og:url" content="https://api.vvhan.com/"/>
    <meta itemprop="image" content="/images/logo.webp"/>
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"/>
    <link rel="stylesheet" type="text/css" href="../css/main.min.css"/>
    <link rel="stylesheet" type="text/css" href="../css/ashes.min.css"/>
    <title>BMI Calculator</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 40px;
            padding: 0;
            background-color: #f0f0f0;
        }

        .container {
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            max-width: 400px;
            margin: 0 auto;
        }

        .container h1 {
            text-align: center;
            margin-bottom: 20px;
        }

        .container label {
            display: block;
            margin: 15px 0 5px;
        }

        .container input {
            width: 100%;
            padding: 8px;
            margin-bottom: 10px;
            border-radius: 4px;
            border: 1px solid #ccc;
        }

        .container button {
            width: 100%;
            padding: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }

        .container button:hover {
            background-color: #0056b3;
        }

        .result {
            margin-top: 20px;
            font-size: 18px;
            text-align: center;
        }
    </style>
</head>

<body>
<img src="/images/logo.webp" alt="logo" style="display: none"/>
<section class="fixed-section">
    <canvas class="vh-bg"></canvas>
    <div class="vh_boy"></div>
</section>
<script src="../js/jquery.min.js"></script>
<section class="page">

    <h2>IP地址查询</h2>
    <form id="main_form" action="./phone.html"  method="POST">
        <p class="clearfix">
            <label class="form_left">请输入IP地址</label>
            <input type="text" id="k"  name="mobile" class="i-text phone_number" value="">
            <button type="submit" name="operate" value="query" class=" waves-effect">查询</button>
        </p>
        <h3>查询结果</h3>
        <div id="result">
        </div>
    </form>
    <script>
        document.getElementById("main_form").addEventListener("submit", function (event) {
            event.preventDefault(); // 阻止默认提交事件
            const ip = document.getElementById("k").value;

            if (!ip) {
                alert("请输入IP地址！");
                return;
            }

            const url = `https://api.vvhan.com/api/ipInfo?ip=${ip}`
            fetch(url)
                .then(response => response.json())
                .then(data => {
                    const template = document.getElementById("template").innerHTML;
                    const result = document.getElementById("result");
                    const html = template.replace("{{mobile}}", data.ip)
                        //{"success":true,"phone":"15555565656","info":{"op":"中国联通","province":"安徽","city":"马鞍山","zipcode":"243000","areacode":"0555"}}
                        .replace("{{areacode}}", data.info.country)
                        .replace("{{province}}", data.info.prov)
                        .replace("{{city}}", data.info.city)
                        .replace("{{postcode}}", '')
                        .replace("{{corp}}", data.info.isp);
                    result.innerHTML = html;
                })
                .catch(error => {
                    console.error("Error:", error);
                    alert("查询失败，请稍后再试。");
                });

        });
    </script>

    <script id="template" type="template">
        <table class="tbl" width="99%" border="0" cellpadding="0" cellspacing="0">
            <tbody>
            <tr>
                <td colspan="2"><h4 style="margin: 0;">查询结果</h4></td>
            </tr>
            <tr>
                <td>{{mobile}}</td>
            </tr>
            <tr>
                <td>{{areacode}}</td>
            </tr>
            <tr>
                <td>{{province}} {{city}}</td>
            </tr>

            </tbody>
        </table>
    </script>
    <svg class="vh-bolang" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
         viewBox="0 24 150 28" preserveAspectRatio="none">
        <defs>
            <path id="vh-bolang-item"
                  d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"></path>
        </defs>
        <g class="vh-bolang-main">
            <use xlink:href="#vh-bolang-item" x="50" y="0" fill="rgba(224,233,239,.5)"></use>
            <use xlink:href="#vh-bolang-item" x="50" y="3" fill="rgba(224,233,239,.5)"></use>
            <use xlink:href="#vh-bolang-item" x="50" y="6" fill="rgba(224,233,239,.5)"></use>
        </g>
    </svg>
    <section class="ξvh-toast"></section>
    <script src="../js/main.min.js"></script>
    <script src="../js/jquery.min.js"></script>

    <!-- 子页面展示 -->
    <script src="../js/page.js"></script>
    <script src="../js/highlight.min.js"></script>
    <script>
        $(() => hljs.highlightAll());
    </script>

    <!-- 统计代码 -->
    <script charset="UTF-8" id="LA_COLLECT" src="https://sdk.51.la/js-sdk-pro.min.js"></script>
    <script>
        LA.init({id: "JLvourAu9qIUtWYT", ck: "JLvourAu9qIUtWYT"});
    </script>
</section>
</body>
</html>
